package com.servlet;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.beans.LogGroupInfo;
import com.beans.LogInfo;
import com.beans.UserInfo;
import com.dao.HiveDao;
import com.dao.impl.HiveDaoImpl;

import net.sf.json.JSONArray;


@WebServlet("/Hive_LogGroupServlet")
public class Hive_LogGroupServlet extends HttpServlet {
	private HiveDao hiveDao =new HiveDaoImpl();
	protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		UserInfo user=(UserInfo) request.getSession().getAttribute("session_user");
		List<LogGroupInfo> logGroupList =hiveDao.getLogGroupList(user.getUserName());
		
		for(LogGroupInfo log:logGroupList){
			System.out.println(log);
		}
		
		//把数据以json格式的方式传给页面
		JSONArray jsonObj=JSONArray.fromObject(logGroupList);
		response.setContentType("text/html;charset=utf-8");
		response.getWriter().print(jsonObj);
	}

}
